<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Input Type</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
       
        <link rel="stylesheet" href="css/styless.css" type="text/css" media="screen"/>
		<link rel="stylesheet" type="text/css" href="css/admin_templatemo_style.css"  />
	<link rel="stylesheet" type="text/css" href="css/menu.css"  />
	 <link rel="stylesheet" href="css/styless.css" type="text/css" media="screen"/>
	<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
	<script type="text/javascript" src="js/jquery-ui-1.8.22.custom.min.js"></script>
	<link rel="stylesheet" type="text/css" href=" css/jquery-ui-1.8.22.custom.css"/>
        <script type="text/javascript" src="js/sliding.form.js"></script>
		
			<SCRIPT type="text/javascript">
<!--
/*
Credits: Bit Repository
Source: http://www.bitrepository.com/web-programming/ajax/agent_code-checker.html 
*/

pic1 = new Image(16, 16); 
pic1.src = "images/loader.gif";

$(document).ready(function(){

$("#agent_code").change(function() { 

var usr = $("#agent_code").val();

if(usr.length >= 4)
{
$("#status").html('<img src="images/loader.gif" align="absmiddle">&nbsp;Checking availability...');

    $.ajax({  
    type: "POST",  
    url: "check_agent.php",  
    data: "agent_code="+ usr,  
    success: function(msg){  
   
   $("#status").ajaxComplete(function(event, request, settings){ 

	if(msg == 'OK')
	{ 
        $("#agent_code").removeClass('object_error'); // if necessary
		$("#agent_code").addClass("object_ok");
		$(this).html('&nbsp;<img src="images/tick.gif" align="absmiddle">');
	}  
	else  
	{  
		$("#agent_code").removeClass('object_ok'); // if necessary
		$("#agent_code").addClass("object_error");
		$(this).html(msg);
	}  
   
   });

 } 
   
  }); 

}
else
	{
	$("#status").html('<font color="red">The agent_code should have at least <strong>4</strong> characters.</font>');
	$("#agent_code").removeClass('object_ok'); // if necessary
	$("#agent_code").addClass("object_error");
	}

});

});

//-->
</SCRIPT>

<script language="javascript" type="text/javascript">
// Roshan's Ajax dropdown code with php
// This notice must stay intact for legal use
// Copyright reserved to Roshan Bhattarai - nepaliboy007@yahoo.com
// If you have any problem contact me at http://roshanbh.com.np
function getXMLHTTP() { //fuction to return the xml http object
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
    }
	
	
	
function getModel(brandId)
{
  
   var req = getXMLHTTP();
   if (req)
   {
     req.onreadystatechange = function()
     {
      if (req.readyState == 4)
      {
	 // only if "OK"
	 if (req.status == 200)
         {
	    document.getElementById('modeldiv').innerHTML=req.responseText;
	 } else {
   	   alert("There was a problem while using XMLHTTP:\n" + req.statusText);
	 }
       }
      }
   req.open("GET","findmodel.php?brand="+brandId,true);
   req.send();
   }
}

</script>


		<script language="javaScript">
function setVisibility(id) {
if(document.getElementById('bt1').value=='Hide Layer'){
document.getElementById('bt1').value = 'Show Layer';
document.getElementById(id).style.display = 'none';
}else{
document.getElementById('bt1').value = 'Hide Layer';
document.getElementById(id).style.display = 'inline';
}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
</script>
<script>

$("select.quickNav").change(function(){ if ($(this).val()!='') { window.location.href=$(this).val(); } });

</script>
    </head>
    <style>
        span.reference{
            position:fixed;
            left:5px;
            top:5px;
            font-size:10px;
            text-shadow:1px 1px 1px #fff;
        }
        span.reference a{
            color:#555;
            text-decoration:none;
			text-transform:uppercase;
        }
        span.reference a:hover{
            color:#000;
            
        }
        h1{
            color:#ccc;
            font-size:36px;
            text-shadow:1px 1px 1px #fff;
            padding:20px;
        }
    </style>
    <body>
        
       <div id="content">
            <h1>Vehicles</h1>
            <div id="wrapper">
                <div id="steps">
                    <form id="formElem" name="formElem" method="post" enctype= "multipart/form-data">
					
					<?php
					include 'db_connect.php';
					session_start();
					
					
			
						$username = $_SESSION['fname'];
						if (isset(
								$_POST['name'],
								$_POST['categories'], 
								$_POST['description'], 
								$_POST['types'], 
								$_POST['conditions'],
								$_POST['brand'],
								$_POST['model'],
								$_POST['transmission'],
								$_POST['fuel'],
								$_POST['price'],
								$_POST['quantity'],
								$_POST['year']
							
						
						
								
								
								))
							
						
							
							{
							$name =  mysql_real_escape_string(htmlentities(trim($_POST['name'])));
							$categories =  mysql_real_escape_string(htmlentities(trim($_POST['categories'])));
							$description =  mysql_real_escape_string(htmlentities(trim($_POST['description'])));
							
							
							$conditions =  mysql_real_escape_string(htmlentities(trim($_POST['conditions'])));
							$brand =  mysql_real_escape_string(htmlentities(trim($_POST['brand'])));
							$model =  mysql_real_escape_string(htmlentities(trim($_POST['model'])));
							$transmission =  mysql_real_escape_string(htmlentities(trim($_POST['transmission'])));
							$fuel =  mysql_real_escape_string(htmlentities(trim($_POST['fuel'])));
							$price =  mysql_real_escape_string(htmlentities(trim($_POST['price'])));
							$quantity =  mysql_real_escape_string(htmlentities(trim($_POST['quantity'])));
							$year =  mysql_real_escape_string(htmlentities(trim($_POST['year'])));
							$types =  mysql_real_escape_string(htmlentities(trim($_POST['types'])));
							
							
							
							move_uploaded_file($_FILES['picture']['tmp_name'],$_FILES['picture']['name']);
							$picture_type=$_FILES['picture']['type'];
							$filename= $_FILES['picture']['name'];
			
						$pjpeg="image/pjpeg";
						$jpeg="image/jpeg";
						$gif="image/gif";
						$png="image/png";
						$bmp="image/bmp";
						$jps="image/jps";
						
			if ($picture_type == $pjpeg || $picture_type == $jpeg || $picture_type == $gif || $picture_type == $png || $picture_type == $bmp || $picture_type == $jps)
				{
							
							mysql_query("INSERT INTO tblvehicles
										(
										  `name`, 
										 `categories`, 
										  `types`,
										 `description`, 
										
										 `conditions`, 
										 `brand`, 
										 `model`,
										 `transmission`,
										 `fuel`,
										 `price`,
										 `quantity`,
										 `year`,
										`filename`
										 
										
										
										 )
										  
										
										VALUES 
										(
										\"$name\",
										\"Vehicles\",
										\"$types\",
										\"$description\",
										
										\"$conditions\",
										\"$brand\",
										\"$model\",
										\"$transmission\",
										\"$fuel\",
										\"$price\",
										\"$quantity\",
										\"$year\",
										\"$filename\"
										)") 
							
										or die(mysql_error());
										echo "<strong>Successful!<strong>";	
										header ('Location: inputvehicles.php');
					
			}}else{
			echo "Error";
			}
		
		?>
                        <fieldset class="step">
						<legend>Vehicles</legend>
							
							<p>
                                <label for="name">Name</label>
                                <input id="name" name="name" type = "text" />
							</p>
							<p>
							<label for="categories">Categories</label>
                           <select id="categories" name = "categories" onchange="if(this.options[this.selectedIndex].value != ''){window.top.location.href=this.options[this.selectedIndex].value}"> 
                                    <option value = "add_vehicles.php">Vehicles</option>
                                    <option value = "add_parts.php">Accessories/Parts</option>
									<option value = "add_services.php">Car Services</option>	 
                                </select>
								</p>
								
								<p>
							<label for="types">Types</label>
                           <select id="types" name = "types" >
                          <?php

$query  = "SELECT * FROM tbltypes";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result))
{
?>
<option value="<?php if ($row['types'] ) 
	  { echo $row['types']; } 
	  else { echo $row['types']; } ?>" >
	  
	  
	  <?php if ($row['types'] ) 
	  { echo $row['types']; }
	  else { echo $row['types']; } ?>
      </option>
 <?php } ?>	 
                                </select>
								</p>
							<p>
                                <label for="description">Description</label>
                                <textarea id="description" name="description" type="text" AUTOCOMPLETE=OFF /></textarea>
                            </p>
							
							
							</fieldset>
							<fieldset class="step">
						<legend>Content</legend>
						<p>
							
							<label for="conditions">Conditions</label>
                           <select id="conditions" name = "conditions" >
                          <?php

$query  = "SELECT * FROM tblcondition";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result))
{
?>
<option value="<?php if ($row['conditions'] ) 
	  { echo $row['conditions']; } 
	  else { echo $row['conditions']; } ?>" >
	  
	  
	  <?php if ($row['conditions'] ) 
	  { echo $row['conditions']; }
	  else { echo $row['conditions']; } ?>
      </option>
 <?php } ?>	 
                                </select>
								</p>
							<p>
							
							<label for="brand">Brand</label>
                          
                           <select id = "brand" name="brand" onChange="getModel(this.value)">
	 <?php

$query  = "SELECT * FROM tblbrand";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result))
{
?>
<option value="<?php if ($row['id'] ) 
	  { echo $row['id'], $row['brand']; } 
	  else { echo $row['brand']; } ?>" >
	  
	  
	  <?php if ($row['brand'] ) 
	  { echo $row['brand']; }
	  else { echo $row['brand']; } ?>
	  
	  
      </option>
 <?php } ?>	 
                                </select>
								</p>
							<p> 
                                <label for="model" id = "model">Model</label>
                              
							   <select id ="modeldiv" name="model" />
							   <option>Select Brand First</option>  
							   </select>
							   
                            </p>
							<p>
							 <label for="transmission" id = "transmission">Transmission</label>
                                <select id = "transmission" name="transmission">
	<option value="">Select Transmission</option>
	<option value="manual">Manual</option>
	<option value="automatic">Automatic</option>
                                </select>
                            </p>
							
							
                        </fieldset>
						<fieldset class="step">
                            <legend>Content Cont </legend>
							
							
                             <p>
                              <label for="fuel" id = "fuel">Fuel</label>
                                <select id = "fuel" name="fuel">
	<option value="">Select Fuel</option>
	<option value="gasoline">Gasoline</option>
	<option value="diesel">Diesel</option>
	<option value="lpg">LPG</option>
	<option value="hybrid">Hybrid</option>
	<option value="electric">Electric</option>
	
                                </select>
							 
                            </p>
							<p>
                                <label for="price">Price</label>
                               <input id="price" name="price" type="text" AUTOCOMPLETE=OFF />
                            </p>
							<p>
                                <label for="quantity">Quantity</label>
                               <input id="quantity" name="quantity" type="text" AUTOCOMPLETE=OFF />
                            </p>
							
							<p>
                                <label for="year">Year</label>
                               <input id="year" name="year" type="text" AUTOCOMPLETE=OFF />
                            </p>
                           
                        </fieldset>
						
						<fieldset class="step">
                            <legend>Upload</legend>
							
							 <p>
                                <label for ="picture">Picture</label>
								<input type="hidden" name="MAX_FILE_SIZE" value="10485760">
								<input id = "picture" type="file" name="picture"> Maxsize 1MB</font>
                            </p>
							
							
							 </fieldset>
						
						<fieldset class="step">
                            <legend>Confirm</legend>
							<p>
								Please fill up all the missing fields before you proceed
							</p>
                            <p class="submit">
                                <button id="registerButton" type="submit" name = "submit">Submit</button>
                            </p>
                        </fieldset>
                    </form>
                </div>
                <div id="navigation" style="display:none;">
                    <ul>
                        <li class="selected">
                            <a href="#">Vehicles</a>
                        </li>
						<li>
                            <a href="#">Content</a>
                        </li>
						<li>
                            <a href="#">Content Cont</a>
                        </li>
						<li>
                            <a href="#">Upload</a>
                        </li>
              
						<li>
                            <a href="#">Confirm</a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
   